local rolely_cangjin = fk.CreateSkill {
    name = "rolely_cangjin",
    tags = { Skill.Limited }
}
Fk:loadTranslationTable {
    ["rolely_cangjin"] = "苍尽",
    [":rolely_cangjin"] = "限定技，任意回合结束时，若牌堆已进行过洗牌，或当你受到致命伤害时，你失去所有技能，将体力回复至上限的一半，获得〖暴军〗、〖雷祸〗、〖起义〗并立刻执行一个额外回合。",

    ["$rolely_cangjin1"] = " ",
    ["$rolely_cangjin2"] = " ",
}
rolely_cangjin:addEffect(fk.TurnEnd, {
    anim_type = "support",
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(rolely_cangjin.name) and player:getMark("rolely_cangjin-turn") > 0 and
            player:usedSkillTimes(rolely_cangjin.name, Player.HistoryGame) == 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local x = player.maxHp // 2
        if player.hp < x then
            player.room:recover {
                who = player,
                num = x - player.hp,
                recoverBy = player,
                skillName = rolely_cangjin.name
            }
        end
        player.room:changeHero(player, "rolely__zhangjiaolv2", false, false, true, false, false)
        player:gainAnExtraTurn(false, rolely_cangjin.name)
    end,
})

rolely_cangjin:addEffect(fk.AfterDrawPileShuffle, {
    can_refresh = function(self, event, target, player, data)
        return player:hasSkill(rolely_cangjin.name)
    end,
    on_refresh = function(self, event, target, player, data)
        player.room:setPlayerMark(player, "rolely_cangjin-turn", 1)
    end,
})
rolely_cangjin:addEffect(fk.DamageInflicted, {
    anim_type = "defensive",
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(rolely_cangjin.name) and
            data.damage >= (player.hp + player.shield) and
            player:usedSkillTimes(rolely_cangjin.name, Player.HistoryGame) == 0
    end,
    on_cost = Util.TrueFunc,
    on_use = function(self, event, target, player, data)
        local x = player.maxHp // 2
        if player.hp < x then
            player.room:recover {
                who = player,
                num = x - player.hp,
                recoverBy = player,
                skillName = rolely_cangjin.name
            }
        end
        player.room:changeHero(player, "rolely__zhangjiaolv2", false, false, true, false, false)
        player:gainAnExtraTurn(false, rolely_cangjin.name)
    end,
})
return rolely_cangjin
